/*
 * @Description: 前端任务管理
 * @Author: Sang Hao
 * @Date: 2021-09-15 17:05:15
 * @LastEditTime: 2021-11-09 20:12:46
 * @LastEditors: Sang Hao
 */
#ifndef LIDAR_SLAM_MAPPINT_FRONT_END_FRONT_END_FLOW_HPP_
#define LIDAR_SLAM_MAPPINT_FRONT_END_FRONT_END_FLOW_HPP_

#include <ros/ros.h>

#include "lidar_slam/subscriber/cloud_subscriber.hpp"
#include "lidar_slam/publisher/odometry_publisher.hpp"
#include "lidar_slam/mapping/front_end/front_end.hpp"


namespace lidar_slam {
class FrontEndFlow {
private:
	/* data */
	std::shared_ptr<CloudSubscriber> cloud_sub_ptr_;
	std::shared_ptr<OdometryPublisher> laser_odom_pub_ptr_;
	std::shared_ptr<FrontEnd> front_end_ptr_;

	/* deque变量，用来在成员函数之间完成参数的传递 */
	std::deque<CloudData> cloud_data_buff_;
	CloudData current_cloud_data_;
	Eigen::Matrix4f laser_odometry_ = Eigen::Matrix4f::Identity();

	
private:
	bool ReadData();
	bool HasData();
	bool ValidData();
	bool UpdateLaserOdometry();
	bool PublishData();

// 只保留的对外接口
public:
	FrontEndFlow(ros::NodeHandle& nh);
	bool Run();
};

}

#endif